package com.boarsoft.boar.message.adapter;

import com.boarsoft.message.bean.MessageEntity;
import com.boarsoft.message.bean.MessageQueryParam;
import com.boarsoft.message.bean.TargetMQ;
import com.boarsoft.message.bean.TargetQueueInfo;
import com.boarsoft.message.broker.MessageBroker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.List;
import java.util.Map;

/**
 * 消息broker适配器，供message-web调用: <br>
 * 1、队列初始化，实现队列的动态添加、删除和查询<br>
 * 2、队列监控，向message-web返回队列监控信息<br>
 * 
 * @author Mac_J
 *
 */
@Component
public class MessageBrokerAdapter {

	@Autowired
	private ApplicationContext applicationContext;

	private Map<String, MessageBroker> messageBrokerMap;

	@PostConstruct
	public void init() {
		messageBrokerMap = applicationContext.getBeansOfType(MessageBroker.class);
	}

	public MessageBroker getMessageBroker(String broker){
		return messageBrokerMap.get(broker);
	}
	public List<MessageBroker> getMessageBrokers(){
		return (List<MessageBroker>) messageBrokerMap.values();
	}
}